libname dd 'D:\data\';


DATA x;
set dd.scores;

kmathtx = kmatht;
kreadtx = kreadt;
kmathsx = kmaths;
kreadsx = kreads;


proc sort;  by quart;  run;

proc standard data = x out = s1 vardef = weight
              mean = 0 std = 1 print;  by quart;
			  var kmathtx;
			  weight wkr0;
			  run;

proc means;
run;

proc standard data = x out = s2 vardef = weight
              mean = 0 std = 1 print;  by quart;
			  var kreadtx;
			  weight wkr0;
			  run;

proc means;
run;

proc standard data = x out = s3 vardef = weight
              mean = 0 std = 1 print;  by quart;
			  var kmathsx;
			  weight wkr0;
			  run;

proc means;
run;

proc standard data = x out = s4 vardef = weight
              mean = 0 std = 1 print;  by quart;
			  var kreadsx;
			  weight wkr0;
			  run;

proc means;
run;

data a1;
set s1;
keep i_id kmathtx;
proc sort;  by i_id;  run;

data a2;
set s2;
keep i_id kreadtx;
proc sort;  by i_id;  run;

data a3;
set s3;
keep i_id kmathsx;
proc sort;  by i_id;  run;

data a4;
set s4;
keep i_id kreadsx;
proc sort;  by i_id;  run;

data dd.scores2;
merge a1 a2 a3 a4;  by i_id;  run;

proc means;
run;
